package org.abc.fund.entity.factorEntity;
import com.fasterxml.jackson.annotation.JsonBackReference;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.CreationTimestamp;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 风格因子数据实体类
 */
@Entity
@Table(
        name = "style_factor_history",
        uniqueConstraints = @UniqueConstraint(columnNames = {"style_factor", "fund_code", "calculation_date"})
)
@Data
@EqualsAndHashCode(callSuper = false)
public class StyleFactorData {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    /**
     * 风格因子
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "style_factor", nullable = false)
    @JsonBackReference("styleFactor-historyData")
    private StyleFactor styleFactor;
    /**
     * 基金代码
     */
    @Column(nullable = false, length = 20)
    private String fundCode;
    /**
     * 计算日期
     */
    @Column(nullable = false)
    private LocalDate calculationDate;
    /**
     * 因子值
     */
    @Column(nullable = false)
    private BigDecimal factorValue;
    /**
     * 修改时间
     */
    @CreationTimestamp
    @Column(nullable = false, updatable = false)
    private LocalDateTime createTime;
    // ========== 补全getter/setter ==========
    public Long getId() { return id; }
    public void setId(Long id) { this.id = id; }
    public StyleFactor getStyleFactor() { return styleFactor; }
    public void setStyleFactor(StyleFactor styleFactor) { this.styleFactor = styleFactor; }
    public String getFundCode() { return fundCode; }
    public void setFundCode(String fundCode) { this.fundCode = fundCode; }
    public void setFactorValue(BigDecimal factorValue) { this.factorValue = factorValue; }
    public LocalDate getCalculationDate() { return calculationDate; }
    public void setCalculationDate(LocalDate calculationDate) { this.calculationDate = calculationDate; }
    public BigDecimal getFactorValue() { return factorValue; }

    public LocalDateTime getCreateTime() { return createTime; }
    public void setCreateTime(LocalDateTime createTime) { this.createTime = createTime; }
}
